/*
 * @description:
 * @Author: FengKongLi
 * @Date: 2022-09-26 15:31:53
 * @LastEditors: FengKongLi
 * @LastEditTime: 2022-09-26 15:32:52
 */

export default {
  methods: {
    /**
     * 数组切割,按照指定大小将一个数组分成多个数组
     * @param {*} arr
     * @param {*} size
     */
    arrayChunk(arr, size) {
      if (arr && arr.length > 0 && size >= 1) {
        let arrLength = arr.length,
          index = 0,
          resultIndex = 0;
        let result = new Array(Math.ceil(arrLength / size));
        while (index < arrLength) {
          result[resultIndex++] = arr.slice(index, (index += size));
        }
        return result;
      } else {
        return [];
      }
    },
  },
};
